package com.xgy.ordering.dto;

import java.util.List;

/**
 * 测试结果类
 */
public class TestResults {
    private int dataSize;
    private String testType;
    private int iterations;
    private List<Double> arrayListTimes;
    private List<Double> linkedListTimes;
    private List<Double> smartListTimes;

    // getters and setters
    public int getDataSize() {
        return dataSize;
    }
    public void setDataSize(int dataSize) {
        this.dataSize = dataSize;
    }

    public String getTestType() {
        return testType;
    }
    public void setTestType(String testType) {
        this.testType = testType;
    }

    public int getIterations() {
        return iterations;
    }
    public void setIterations(int iterations) {
        this.iterations = iterations;
    }

    public List<Double> getArrayListTimes() {
        return arrayListTimes;
    }
    public void setArrayListTimes(List<Double> arrayListTimes) {
        this.arrayListTimes = arrayListTimes;
    }

    public List<Double> getLinkedListTimes() {
        return linkedListTimes;
    }
    public void setLinkedListTimes(List<Double> linkedListTimes) {
        this.linkedListTimes = linkedListTimes;
    }

    public List<Double> getSmartListTimes() {
        return smartListTimes;
    }
    public void setSmartListTimes(List<Double> smartListTimes) {
        this.smartListTimes = smartListTimes;
    }


    public double getArrayListAvg() {
        return arrayListTimes.stream().mapToDouble(Double::doubleValue).average().orElse(0);
    }

    public double getLinkedListAvg() {
        return linkedListTimes.stream().mapToDouble(Double::doubleValue).average().orElse(0);
    }

    public double getSmartListAvg() {
        return smartListTimes.stream().mapToDouble(Double::doubleValue).average().orElse(0);
    }

    public boolean hasValidResults() {
        return getArrayListAvg() > 0 && getLinkedListAvg() > 0 && getSmartListAvg() > 0;
    }
}